#include <iostream>
using namespace std;
int n,m;
int mypow(int d,int k);
int main()
{
	while(cin>>m>>n){
		if(m==0&&n==0) break;
		int count=1;
		int height=1;
		int  left,right;
		left=m*2;
		right=m*2+1;
		while(1){
			if(right<n){
				count=count+mypow(2,height);
				height++;
				left=2*left;
				right=2*right+1;
			}
			else {
				if(left>n){
					break;
				}
				else{
					count=count+n-left+1;
					break;
				}
			}
		}
		cout<<count<<endl;
	}
}

int mypow(int d,int k)
{
	int result=1;
	for(int i=0;i<k;i++){
		result=result*d;
	}
	return result;
}
